//二叉树先序遍历的递归实现

class Solution
{
public:
    vector<int> res;

    vector<int> preorderTraversal(TreeNode *root)
    {
        preOrder(root);
        return res;
    }
    
    void preOrder(TreeNode *root)
    {
        if (root != NULL)
        {
            res.push_back(root->val);
            preOrder(root->left);
            preOrder(root->right);
        }
    }
};